<template>
  <el-row>
    <el-col
      v-for="(elem, index) in showingFilmList"
      :key="index"
      :offset="index &gt; 0 ? 1 : 0"
      :class="index % 5 == 0 && index != 0 ? 'movie_col' : '' "
    >
      <el-card shadow="never" :body-style="{ padding: '0px' }">
        <img class="movieImg" :src="elem.filmPicture" />
        <div class="movie_sale">
          <router-link
            :to="{ name: 'cinema', query: { filmInfo: JSON.stringify(elem) } }"
            >购票</router-link
          >
        </div>
      </el-card>

      <div class="movie_info">
        <div class="movie_title">{{elem.filmName}}</div>
        <div class="movie_score">{{elem.filmScore}}</div>
      </div>
    </el-col>
  </el-row>
</template>
<script>
export default {
  data() {
    return {
        showingFilmList:[],
        cateName:this.$route.query.cateName,
        query:{}
    };
  },
  created() {
   
    this.query = this.$route.query
    this.getMovieList()
  },

  watch:{
      $route(to, from) {
         this.query = this.$route.query
          this.getMovieList()
      }
  },
  methods: {
         async getMovieList() {
        this.showingFilmList = []
      const { data: res } = await this.$http.post("/common/filminfo/getList",this.query);
      console.log(res);
      if (res.code != 200) {
        return this.$message.error(res.message);
      } else {
        var temp = res.data.value;
        temp.forEach((element) => {
          if (element.filmStatus == "上映") {
            this.showingFilmList.push(element);
          } 
        });
      }
    },
  },
};
</script>
<style lang="less" scoped>
.el-row{
    min-height: 285px;
}
.el-card {
  width: 200px;
  height: 332px;
  font-size: 0;
}
.movieImg {
  width: 100%;
  height: 286.1px;
}
.movie_info {
  width: 100%;
  color: #fff;
  position: absolute;
  bottom: 57px;
  overflow: hidden;
}
.movie_title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 10px;
  float: left;
}
.movie_score {
  color: #ffb400;
  float: right;
  margin-right: 7px;
}
.el-col {
  position: relative;
  width: 17%;
}
.coming_soon,.notice {
  margin-top: 20px;
}
.movie_sale {
  text-align: center;
  height: 46px;
  line-height: 46px;
  text-decoration: none;
  background: #fff;
  font-size: 16px;

  a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
  }
  a:hover {
    background-color: #ef4238;
    color: #fff;
  }
}
.el-col-offset-1 {
    margin-left: 3.16667%;
}
.movie_col{
  margin-top:20px;
  margin-left:0;
}
</style>